package controller;

import model.entity.Entity;

public class ControlMovementMediator {
	
	private class MoveNorth implements Command{
		
		ControlMovementMediator m;
		
		public MoveNorth(ControlMovementMediator m) {
			this.m = m;
		}
		public void execute() {
			m.moveNorth();
		}
	}
	
	private class MoveNE implements Command{
		
		ControlMovementMediator m;
		
		public MoveNE(ControlMovementMediator m) {
			this.m = m;
		}

		@Override
		public void execute() {
			m.moveNE();
			
		}

	}
	
	private class MoveNW implements Command {

		ControlMovementMediator m;
		
		public MoveNW(ControlMovementMediator m) {
			this.m = m;
		}

		@Override
		public void execute() {
			m.moveNW();
			
		}

	}
	
	private class MoveSouth implements Command{
		
		ControlMovementMediator m;
		
		public MoveSouth(ControlMovementMediator m) {
			this.m = m;
		}

		public void execute() {
		 m.moveSouth();
		}
	}
	
	private class MoveSE implements Command {

		ControlMovementMediator m;
		
		public MoveSE(ControlMovementMediator m) {
			this.m = m;
		}
		
		@Override
		public void execute() {
			m.moveSE();

		}

	}
	
	private class MoveSW implements Command {

		ControlMovementMediator m;
		
		public MoveSW(ControlMovementMediator m) {
			this.m = m;
		}
		
		@Override
		public void execute() {
			m.moveSW();

		}

	}

		private Entity controlledEntity;
	public ControlMovementMediator(Entity controlledEntity) {
		this.controlledEntity = controlledEntity;
		KeyController.addMoveNorth(new MoveNorth(this));
		KeyController.addMoveNortheast(new MoveNE(this));
		KeyController.addMoveNorthwest(new MoveNW(this));
		KeyController.addMoveSouth(new MoveSouth(this));
		KeyController.addMoveSoutheast(new MoveSE(this));
		KeyController.addMoveSouthwest(new MoveSW(this));
	}

	private void moveNorth() {
		ScrollMediator.clear();
		controlledEntity.commandMoveNorth();
	}
	
	private void moveNE() {
		ScrollMediator.clear();
		controlledEntity.commandMoveNE();
	}
	
	private void moveNW() {
		ScrollMediator.clear();
		controlledEntity.commandMoveNW();
		
	}
	
	private void moveSouth() {
		ScrollMediator.clear();
		controlledEntity.commandMoveSouth();
	}
	
	private void moveSE() {
		ScrollMediator.clear();
		controlledEntity.commandMoveSE();
	}
	
	private void moveSW() {
		ScrollMediator.clear();
		controlledEntity.commandMoveSW();
		
	}

}
